<script type="text/javascript">
    //<![CDATA[
    function clear_log(btn) {
        XHR.get('<%=url([[admin]], [[services]], [[mosdns]], [[clear_log]])%>', null,
            function(x, data) {
                if(x && x.status == 200) {
                    var log_textarea = document.getElementById('log_textarea');
                    log_textarea.innerHTML = "";
                    log_textarea.scrollTop = log_textarea.scrollHeight;
                }
                location.reload();
            }
        );
    }
    var scrolled = false;
    XHR.poll(2, '<%=url([[admin]], [[services]], [[mosdns]], [[get_log]])%>', null,
        function(x, data) {
            if(x && x.status == 200) {
                var log_textarea = document.getElementById('log_textarea');
                log_textarea.innerHTML = x.responseText;
                if (!scrolled) {
                    log_textarea.scrollTop = log_textarea.scrollHeight;
                    scrolled = true;
                }
            }
        }
    );
    //]]>
</script>
<fieldset class="cbi-section" id="_log_fieldset">
    <input class="btn cbi-button-action" type="button" onclick="clear_log()" value="<%:Clear logs%>" style="margin-left: 10px; margin-top: 10px;">
    <textarea id="log_textarea" class="cbi-input-textarea" style="width: calc(100% - 20px); height: 645px; margin: 10px;" data-update="change" rows="5" wrap="off" readonly="readonly"></textarea>
</fieldset>
